package com.company.nuwa.common.utils;

import org.apache.commons.lang3.StringUtils;

/**
 * The class is responsible for PhoneNumberUtils
 *
 * @author renzheng
 * @date 2023/12/26
 */
public class PhoneNumberUtils {

    /**
     * 获取手机号后四位
     *
     * @param phoneNumber 手机号
     * @return 0000
     */
    public static String getLastFourDigits(String phoneNumber) {
        int phoneNumberLength = 11;
        // 检查输入是否为有效的手机号
        if (StringUtils.isBlank(phoneNumber) || phoneNumber.length() != phoneNumberLength) {
            return "";
        }
        return phoneNumber.substring(phoneNumberLength - 4);
    }

    public static void main(String[] args) {
        System.out.println(getLastFourDigits("13123122121"));
    }

}
